package com.itheima.service.impl;

import com.itheima.dao.GoodsDao;
import com.itheima.dao.OrderDao;
import com.itheima.dao.UserDao;
import com.itheima.dao.impl.GoodsDaoImpl;
import com.itheima.dao.impl.OrderDaoImpl;
import com.itheima.dao.impl.UserDaoImpl;
import com.itheima.domain.Goods;
import com.itheima.domain.Order;
import com.itheima.domain.User;
import com.itheima.service.OrderService;

public class OrderServiceImpl implements OrderService {

    //TODO 改为使用自动装配方式赋值
    private OrderDao orderDao ;//= new OrderDaoImpl();
    private UserDao userDao   ;//= new UserDaoImpl();
    private GoodsDao goodsDao  ;//= new GoodsDaoImpl();

    public void setOrderDao(OrderDao orderDao) {
        this.orderDao = orderDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public void setGoodsDao(GoodsDao goodsDao) {
        this.goodsDao = goodsDao;
    }

    public void placeOrder(Order order, User user, Goods goods) {
        userDao.get(user);
        goodsDao.updateNum(goods);
        orderDao.save(order);
    }
}
